#include"../../comm/detail.hpp"
#include"../../server/rpc_server.hpp"

using namespace std;
using namespace MuduoNet;
using namespace Message;
using namespace Dispatch;
using namespace Server;

void Add(const Json::Value &req, Json::Value &rsp) {
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = num1 + num2;
    DLog("Add:%d", rsp.asInt());
}
int main()
{
    unique_ptr<Server::SDescribeFactory> desc_factory(new SDescribeFactory());

    desc_factory->setMethodName("Add");
    desc_factory->setParamsDesc("num1",Server::VType::INTEGRAL);
    desc_factory->setParamsDesc("num2",Server::VType::INTEGRAL);
    desc_factory->setReturnType(Server::VType::INTEGRAL);
    desc_factory->setCallback(Add);
    
    Server::RpcServer server(Address("127.0.0.1",9090),true,Address("127.0.0.1",9010));
    server.RegistryMethod(desc_factory->build());
    server.Start();
    return 0;
}